<template>
	
 	<div class="layui-layout layui-layout-admin" >
 	  <div class="adminnav1">	
        <Pagetop></Pagetop>
      </div>
      <div class="adminnav2">	
       	<Secondnav urlname="retail"></Secondnav>
      </div>
      
      <!-- 主体内容 -->
      <div class="layui-body kedou-admin" id="LAY_app_body app">
	    <div class="layadmin-tabsbody-item layui-show">
	    	<div class="pagelist">
	    		<div class="layui-card-body">
		      		<fieldset class="layui-elem-field layui-field-title">
					  <legend>推广员管理(分享商)</legend>
					</fieldset>
		      	</div>
	    		<div class="pagetop">
	    			<Search :seadate="searchArr"></Search>			    	
		        </div>
		        <div class="layui-card-body">
		        	<div class="buttop">
					    <button type="button" class="layui-btn  layui-btn-normal" @click="addData">添加推广员（分享商）</button>
					</div>
			        <Tables :fdate="pdate" :result="res" height="430" :totalCount="totalRows" :pageNumber="curindex" :fbtn="btn"></Tables>      			     
		        </div>		      
	        </div>
	    </div>
	  </div>  
	     
	</div>
</template>
<script>	
	import Pagetop from '../common/pagetop.vue'
	import Secondnav from '../common/secondnav.vue'
	import Tables from '../common/tables.vue'
	import Search from '../common/search.vue'
	export default {
	  name: 'promoterlist',
	  components: {Pagetop,Secondnav,Tables,Search},	  
	  data () {
	    return {
	        pdate:[], //表头  	
	    	res:"", //内容
	    	totalRows:"",//总数量
	    	curindex:1, //页数
	    	btn:[],//按钮
	    	searchArr:[],//搜索
	    	isShow:false, 
	    	seapram:''   	
	    }
	  },
	  mounted(){ 	
	  	this.getdate();
     	this.getsearch();
	  },
	  methods: {	 	  
		getdate:function(){     	
    	var _this=this;    	    	
    	var url="/retail/bapi/v1.9/sharer"    	
    	if(_this.seapram){
    		var dates={
	    		 size:pageSize,
	    		 page:_this.curindex,
		         //sort:'createAt,DESC',
		         //'status.equals':'ENABLE'
	    	}
    		var res=_this.seapram;
    		for(var i=0;i<res.length;i++){
    			dates[res[i].key]=res[i].val;
    		}    		
    	}else{
	    	var dates={
	    		size:pageSize,
	    		page:_this.curindex,
          		//sort:'createAt,DESC',
          		//'status.equals':'ENABLE'
	    	}
        }  		    	
        	//alert(url+"//"+JSON.stringify(dates))
      	ajaxRequest(url,'GET','json',dates,function(ret,err){
      		//alert(url+"//"+JSON.stringify(ret))
	  		var arr=[];  		
		  	arr[0]=[ 
		       {field: 'id', title: 'id',}
		      ,{field: 'accountName', title: '用户账号',}
		      ,{field: 'nickName', title: '昵称',}
		      ,{field: 'phone', title: '用户手机号',}		      
		      ,{field: 'amount', title: '累计金额(元)',templet:function(d){return d.amount/100}}
		      ,{field: 'createAt', title: '创建日期',templet:function(d){return FormatDate(d.createAt,2)}}
		      ,{field: 'teamUserName', title: '团队归属名称',}
		      ,{field: 'referrer', title: '上级实体',templet:function(d){return d.referrer.accountName}}
//		      ,{field: 'subordinate', title: '下级数组',}			     			     
		      ,{field: 'right',title: '操作', width:'120', fixed:'right',templet:function(d){
		      	 var str='<a class="layui-btn layui-btn-xs  layui-btn-normal" lay-event="edit">变更上级</a>';
//		      	 var str1='<a class="layui-btn layui-btn-xs " lay-event="detail">详情</a>';		         
		         return str;
		      }}
		    ];
		    var res1=[]
		    res1=[{a:'1',b:100,b1:0,b2:100,c:'无',c1:1,d:'1团队分享商',e:'无'},{a:'2',b:100,b1:0,b2:100,c:'无',c1:1,d:'1团队分享商',e:'无'},]	    		  	
		  	
		  	_this.pdate=arr;		  	
		  	_this.res=ret.data.list; //res1;		 
		  	_this.totalRows=ret.data.totalRows;
		  	_this.curindex=ret.data.pageNumber;		  	
	    })	
    },     
     getsearch:function(){
    	var arr=[
    		{field: 'phone', title: '手机号',type: 'input'}     	
    	];
    	this.searchArr=arr;   	
    },
    page:function(index,obj){
    	//alert(JSON,stringify(obj))
    	this.curindex=index;
    	this.getdate();    	
    }, 
    sousuo:function(pram){
    	//alert(JSON.stringify(pram))
    	this.seapram=pram;
    	this.res='';
    	this.totalRows='';
    	this.curindex=1;
    	this.getdate();
    },
    addData:function(){     
       // this.$router.push({name:'promoteradd'})
        var _this = this;
        var datas={			
			from:1,
		}
		layer.open({
	        type: 2
	        ,title: '开通推广员（分享商）'		        
	        ,content:baseurl+'promoteradd'
	        ,area: _this.screens() < 2 ? ['80%', '60%'] : ['500px', '400px']
	        ,success : function(layero, index){
		        var iframeWin = window[layero.find('iframe')[0]['name']];
		        iframeWin.getdates(datas);
	        },
        });	
	},
	editInfo:function(data){
		//this.$router.push({name:'jfadd',query:{'shopId':data.shopId,'commodityId':data.commodityId}})	
		var _this = this;
		var datas={
			id:data.id,
//			accountId:data.accountId,
//			accountName:data.accountName,			
			from:2,
		}
		//alert(JSON.stringify(datas))
		layer.open({
            type: 2
            ,title: '更变上级信息'
            ,shadeClose: false//点击遮罩关闭
            ,content:baseurl+'promoteradd'
            ,area: _this.screens() < 2 ? ['80%', '80%'] : ['500px', '400px']          
            ,success : function(layero, index){
		        var iframeWin = window[layero.find('iframe')[0]['name']];
		        iframeWin.getdates(datas);
	        },	      
        }); 
	},
	detailInfo:function(data){
//		var _this = this;
//		var datas={
//			id:data.id,
//			//where:2,
//		}
//		layer.open({
//          type: 2
//          ,title: '详情信息'
//          ,shadeClose: false//点击遮罩关闭
//          ,content:baseurl+'promoteradd'
//          ,area: _this.screens() < 2 ? ['90%', '80%'] : ['650px', '650px']          
//          ,success : function(layero, index){
//		        var iframeWin = window[layero.find('iframe')[0]['name']];
//		        iframeWin.getdates(datas);
//	        },	      
//      });
	},
	screens:function(){
		return screen();
	},	
  },
  updated:function(){
  	this.isShow = true;
	layui.use('form', function(){
	  var form = layui.form;
	  form.render();	 
	});
  },
}
</script>
<style scoped>
/**/
</style>
